<!DOCTYPE html>


<html lang="zn-CH">


<head>
  <meta charset="utf-8" />
    
  <meta name="description" content="What I can do is to Do My Personal Best!" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    java按需导出Excel并自动合同单元格 |  小熊的博客
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="http://www.cdn.adingxiong.com/b5363a06dc744d79a94021492bcefe27" />
  
  
<link rel="stylesheet" href="/blog/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/blog/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/blog/atom.xml" title="小熊的博客" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content on">
      <section class="outer">
  <article id="post-java按需导出Excel并自动合同单元格" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  java按需导出Excel并自动合同单元格
</h1>
 

    </header>
    

    
    <div class="article-meta">
      <a href="/blog/2020/11/12/java%E6%8C%89%E9%9C%80%E5%AF%BC%E5%87%BAExcel%E5%B9%B6%E8%87%AA%E5%8A%A8%E5%90%88%E5%90%8C%E5%8D%95%E5%85%83%E6%A0%BC/" class="article-date">
  <time datetime="2020-11-12T02:25:41.000Z" itemprop="datePublished">2020-11-12</time>
</a>
      
      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">2.3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">13 min</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <h3 id="java导出excel并单元格自动合并"><a href="#java导出excel并单元格自动合并" class="headerlink" title="java导出excel并单元格自动合并"></a>java导出excel并单元格自动合并</h3><p>最近公司有一个需求,就是按到模版导出数据报表,并内容相同的单元格实现自动合并.具体业务设计图如下所示<br><img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/bd7801d504a6453caa67c688ce423d43~tplv-k3u1fbpfcp-watermark.image" alt></p>
<h4 id="需求分析"><a href="#需求分析" class="headerlink" title="需求分析"></a>需求分析</h4><ol>
<li>由于头部是固定不变的,先使用excel创建数据模版</li>
<li>单元格合并,前三列需要根据内容相同自动合并单元格</li>
<li>根据状态来判断,状态异常的红色字体,并且已红色<code>×</code>标识</li>
<li>*情况,都是多选一的,数据库只会记录一种状态,后台需要判断并在指定的单元格添加标识符<code>√</code></li>
</ol>
<h4 id="代码开发"><a href="#代码开发" class="headerlink" title="代码开发"></a>代码开发</h4><ol>
<li><p>创建*情况对应的魔法值对比索引</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@ClassName</span> PatrolExportEnum</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Description</span>   方便单元格选择勾选</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span> xiongchao</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span> 2020/10/20 10:02</span></span><br><span class="line"><span class="comment"> **/</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span>  <span class="title">PatrolExportEnum</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 进水情况</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Map&lt;String,Integer&gt; waterInCondition;</span><br><span class="line">    <span class="comment">// 出水情况</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Map&lt;String,Integer&gt; waterOutCondition;</span><br><span class="line">    <span class="comment">// 电力情况</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Map&lt;String,Integer&gt; electryCondition;</span><br><span class="line">    <span class="comment">// 是否与现场一直</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Map&lt;String,Integer&gt; liveCondition;</span><br><span class="line">    <span class="comment">// 管网情况</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Map&lt;String,Integer&gt; pipeCondition;</span><br><span class="line">    <span class="comment">// 配水情况</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Map&lt;String,Integer&gt; waterCondition;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">static</span> &#123;</span><br><span class="line"></span><br><span class="line">        waterInCondition = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">        waterOutCondition = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">        electryCondition = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">        liveCondition = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">        pipeCondition = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">        waterCondition = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line"></span><br><span class="line">        waterInCondition.put(<span class="string">"无"</span>,<span class="number">0</span>);</span><br><span class="line">        waterInCondition.put(<span class="string">"少"</span>,<span class="number">1</span>);</span><br><span class="line">        waterInCondition.put(<span class="string">"正常"</span>,<span class="number">2</span>);</span><br><span class="line">        waterInCondition.put(<span class="string">"有溢流"</span>,<span class="number">3</span>);</span><br><span class="line"></span><br><span class="line">        waterOutCondition.put(<span class="string">"正常"</span>,<span class="number">0</span>);</span><br><span class="line">        waterOutCondition.put(<span class="string">"无水"</span>,<span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">        electryCondition.put(<span class="string">"正常"</span>,<span class="number">0</span>);</span><br><span class="line">        electryCondition.put(<span class="string">"故障"</span>,<span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">        liveCondition.put(<span class="string">"一致"</span>,<span class="number">0</span>);</span><br><span class="line">        liveCondition.put(<span class="string">"不一致"</span>,<span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">        pipeCondition.put(<span class="string">"管道"</span>,<span class="number">0</span>);</span><br><span class="line">        pipeCondition.put(<span class="string">"井盖"</span>,<span class="number">1</span>);</span><br><span class="line">        pipeCondition.put(<span class="string">"沉沙井"</span>,<span class="number">2</span>);</span><br><span class="line"></span><br><span class="line">        waterCondition.put(<span class="string">"均匀"</span>,<span class="number">0</span>);</span><br><span class="line">        waterCondition.put(<span class="string">"堵塞"</span>,<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Integer <span class="title">getWaterInCondition</span><span class="params">(String waterIn)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> waterInCondition.get(waterIn);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Integer <span class="title">getWaterOutCondition</span><span class="params">(String waiterOut)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> waterOutCondition.get(waiterOut);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Integer <span class="title">getElectryCondition</span><span class="params">(String electry)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> electryCondition.get(electry);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Integer <span class="title">getLiveCondition</span><span class="params">(String live)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> liveCondition.get(live);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Integer <span class="title">getPipeCondition</span><span class="params">(String pipe)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> pipeCondition.get(pipe);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Integer <span class="title">getWaterCondition</span><span class="params">(String water)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> waterCondition.get(water);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>导出数据实体类 </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">PatrolTaskExport</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String street;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String xVillage;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String zVlillage;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String  patrolTime;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String patrolPerson;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String content;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String waterInCondition;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String waterOutCondition;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String electryCondition;</span><br><span class="line"></span><br><span class="line">   <span class="keyword">private</span> List&lt;equCondition&gt; equConditionList;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String isSame;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> List&lt;equCondition&gt; pipeCondition;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String waterSupport;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String afforestCondition;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getStreet</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> street;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setStreet</span><span class="params">(String street)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.street = street;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getxVillage</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> xVillage;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setxVillage</span><span class="params">(String xVillage)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.xVillage = xVillage;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getzVlillage</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> zVlillage;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setzVlillage</span><span class="params">(String zVlillage)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.zVlillage = zVlillage;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getPatrolTime</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> patrolTime;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPatrolTime</span><span class="params">(String patrolTime)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.patrolTime = patrolTime;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getPatrolPerson</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> patrolPerson;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPatrolPerson</span><span class="params">(String patrolPerson)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.patrolPerson = patrolPerson;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getContent</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> content;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setContent</span><span class="params">(String content)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.content = content;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getWaterInCondition</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> waterInCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setWaterInCondition</span><span class="params">(String waterInCondition)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.waterInCondition = waterInCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getWaterOutCondition</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> waterOutCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setWaterOutCondition</span><span class="params">(String waterOutCondition)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.waterOutCondition = waterOutCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getElectryCondition</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> electryCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setElectryCondition</span><span class="params">(String electryCondition)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.electryCondition = electryCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getIsSame</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> isSame;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setIsSame</span><span class="params">(String isSame)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.isSame = isSame;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> List&lt;equCondition&gt; <span class="title">getPipeCondition</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> pipeCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPipeCondition</span><span class="params">(List&lt;equCondition&gt; pipeCondition)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.pipeCondition = pipeCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getWaterSupport</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> waterSupport;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setWaterSupport</span><span class="params">(String waterSupport)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.waterSupport = waterSupport;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getAfforestCondition</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> afforestCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setAfforestCondition</span><span class="params">(String afforestCondition)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.afforestCondition = afforestCondition;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">equCondition</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="title">equCondition</span> <span class="params">(String name,String value)</span></span>&#123;</span><br><span class="line">            <span class="keyword">this</span>.name = name;</span><br><span class="line">            <span class="keyword">this</span>.value = value;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">private</span> String name;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">private</span> String value;</span><br><span class="line"></span><br><span class="line">        <span class="function"><span class="keyword">public</span> String <span class="title">getName</span><span class="params">()</span> </span>&#123;</span><br><span class="line">            <span class="keyword">return</span> name;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setName</span><span class="params">(String name)</span> </span>&#123;</span><br><span class="line">            <span class="keyword">this</span>.name = name;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="function"><span class="keyword">public</span> String <span class="title">getValue</span><span class="params">()</span> </span>&#123;</span><br><span class="line">            <span class="keyword">return</span> value;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setValue</span><span class="params">(String value)</span> </span>&#123;</span><br><span class="line">            <span class="keyword">this</span>.value = value;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> List&lt;equCondition&gt; <span class="title">getEquConditionList</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> equConditionList;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setEquConditionList</span><span class="params">(List&lt;equCondition&gt; equConditionList)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.equConditionList = equConditionList;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>对应的服务类 </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@ClassName</span> ExcelExportService</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Description</span> TODO</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Author</span> xiongchao</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Date</span> 2020/10/20 10:42</span></span><br><span class="line"><span class="comment"> **/</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">ExcelExportService</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 数据导出,格式转化</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> fileName</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> rootPath</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> list</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function">FileData <span class="title">exportFile</span><span class="params">(String fileName, String rootPath, List&lt;PatrolTaskExport&gt; list)</span></span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 获取导出数据</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> param</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function">List&lt;PatrolTaskExport&gt; <span class="title">getExportData</span><span class="params">(Map&lt;String,Object&gt; param)</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>接口实现类 </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="meta">@Service</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ExcelExportServiceImpl</span> <span class="keyword">implements</span> <span class="title">ExcelExportService</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String yes =<span class="string">"√"</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String no =<span class="string">"×"</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> Logger log = LoggerFactory.getLogger(ExcelExportServiceImpl<span class="class">.<span class="keyword">class</span>)</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> SimpleDateFormat sdf = <span class="keyword">new</span> SimpleDateFormat(<span class="string">"yyyy-MM-dd"</span>);</span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> FileData <span class="title">exportFile</span><span class="params">(String fileName, String rootPath, List&lt;PatrolTaskExport&gt; list)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (CollectionUtils.isEmpty(list)) &#123;</span><br><span class="line">            log.error(<span class="string">"导出数据不能为空!"</span>);</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">null</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        FileData fileData = <span class="keyword">null</span>;</span><br><span class="line">        Sheet sheet = <span class="keyword">null</span>;</span><br><span class="line">        Workbook workbook = <span class="keyword">null</span>;</span><br><span class="line">        Row row = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            workbook= ExcelUtil.readExcel(rootPath);</span><br><span class="line">            CellStyle cellStyle =  workbook.createCellStyle();</span><br><span class="line">            cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);</span><br><span class="line">            cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);</span><br><span class="line">            Font font = workbook.createFont();</span><br><span class="line">            font.setColor(HSSFColor.RED.index);</span><br><span class="line"></span><br><span class="line">            <span class="comment">//导出月份时间</span></span><br><span class="line">            String month = getMonth();</span><br><span class="line">            <span class="keyword">if</span>(workbook != <span class="keyword">null</span>) &#123;</span><br><span class="line">                sheet = workbook.getSheetAt(<span class="number">0</span>);</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(sheet != <span class="keyword">null</span>)&#123;</span><br><span class="line">                <span class="comment">//开始日期</span></span><br><span class="line">                row= sheet.getRow(<span class="number">1</span>);</span><br><span class="line">                row.getCell(<span class="number">0</span>).setCellValue(month);</span><br><span class="line"></span><br><span class="line">                <span class="comment">// 第四行开始写入数据</span></span><br><span class="line">                <span class="keyword">int</span> rowNum = <span class="number">4</span>;</span><br><span class="line">                <span class="keyword">int</span> index = <span class="number">1</span>;</span><br><span class="line">                <span class="comment">//明确只有 2,3,4 需要根据重复内容合并</span></span><br><span class="line">                <span class="comment">//上一个街镇名称</span></span><br><span class="line">                String perPurpose = <span class="string">""</span>;</span><br><span class="line">                String perxVillage = <span class="string">""</span>;</span><br><span class="line">                String perzVliiage= <span class="string">""</span>;</span><br><span class="line">                <span class="comment">//要融合的第一行</span></span><br><span class="line">                <span class="keyword">int</span> startMergeCol = <span class="number">4</span>;</span><br><span class="line">                <span class="keyword">int</span> xStartMergeCol = <span class="number">4</span>;</span><br><span class="line">                <span class="keyword">int</span> zStartMergeCol = <span class="number">4</span>;</span><br><span class="line">                <span class="keyword">int</span> xendMergeCol = <span class="number">3</span>;</span><br><span class="line">                <span class="keyword">int</span> zendMergeCol = <span class="number">3</span>;</span><br><span class="line">                <span class="comment">//要融合的最后行</span></span><br><span class="line">                <span class="keyword">int</span> endMergeCol = <span class="number">3</span>;</span><br><span class="line">                <span class="comment">//勾选的数字</span></span><br><span class="line">                Integer selectIndex = <span class="keyword">null</span>;</span><br><span class="line">                <span class="comment">//用来记录是否是第一次循环</span></span><br><span class="line">                <span class="keyword">boolean</span> flag = <span class="keyword">true</span>;</span><br><span class="line"></span><br><span class="line">                <span class="keyword">int</span> cellNum = sheet.getRow(<span class="number">3</span>).getLastCellNum();</span><br><span class="line">                <span class="comment">//先建单元格</span></span><br><span class="line">                <span class="keyword">for</span>(PatrolTaskExport vo :list)&#123;</span><br><span class="line">                    row = sheet.createRow(rowNum);</span><br><span class="line">                    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;cellNum;i++)&#123;</span><br><span class="line">                        row.createCell(i);</span><br><span class="line">                    &#125;</span><br><span class="line">                    rowNum++;</span><br><span class="line">                &#125;</span><br><span class="line"></span><br><span class="line">                rowNum =<span class="number">4</span>;</span><br><span class="line">                <span class="keyword">for</span>(PatrolTaskExport vo :list)&#123;</span><br><span class="line">                    row = sheet.getRow(rowNum);</span><br><span class="line">                    <span class="comment">//开始写入数据</span></span><br><span class="line">                    createCell(row,cellStyle,<span class="number">0</span>,String.valueOf(index));</span><br><span class="line">                    createCell(row,cellStyle,<span class="number">1</span>,vo.getStreet());</span><br><span class="line">                    <span class="keyword">if</span>(flag)&#123;</span><br><span class="line">                        perPurpose = vo.getStreet();</span><br><span class="line">                        perzVliiage = vo.getzVlillage();</span><br><span class="line">                        perxVillage =vo.getxVillage();</span><br><span class="line">                        flag = <span class="keyword">false</span>;</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    <span class="keyword">if</span>(perzVliiage.equalsIgnoreCase(vo.getzVlillage()))&#123;</span><br><span class="line">                        zendMergeCol ++;</span><br><span class="line">                    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                        <span class="keyword">if</span>(zendMergeCol &gt; zStartMergeCol)&#123;</span><br><span class="line">                            sheet.addMergedRegion(<span class="keyword">new</span> CellRangeAddress(zStartMergeCol,zendMergeCol,<span class="number">3</span>,<span class="number">3</span>));</span><br><span class="line">                        &#125;</span><br><span class="line">                        zStartMergeCol = rowNum;</span><br><span class="line">                        zendMergeCol = zStartMergeCol;</span><br><span class="line">                        perzVliiage = vo.getzVlillage();</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    <span class="keyword">if</span>(perxVillage.equalsIgnoreCase(vo.getxVillage()))&#123;</span><br><span class="line">                        xendMergeCol ++;</span><br><span class="line">                    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                        <span class="keyword">if</span>(xendMergeCol &gt; xStartMergeCol)&#123;</span><br><span class="line">                            sheet.addMergedRegion(<span class="keyword">new</span> CellRangeAddress(xStartMergeCol,xendMergeCol,<span class="number">2</span>,<span class="number">2</span>));</span><br><span class="line">                        &#125;</span><br><span class="line">                        xStartMergeCol = rowNum;</span><br><span class="line">                        xendMergeCol = xStartMergeCol;</span><br><span class="line">                        perxVillage = vo.getxVillage();</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    <span class="keyword">if</span>(perPurpose.equals(vo.getStreet()))&#123;</span><br><span class="line">                        endMergeCol ++;</span><br><span class="line">                    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                        <span class="comment">//并且之前相同的单元格</span></span><br><span class="line">                        <span class="keyword">if</span>(startMergeCol &lt; endMergeCol)&#123;</span><br><span class="line">                            sheet.addMergedRegion(<span class="keyword">new</span> CellRangeAddress(startMergeCol,endMergeCol,<span class="number">1</span>,<span class="number">1</span>));</span><br><span class="line">                        &#125;</span><br><span class="line">                        startMergeCol = rowNum;</span><br><span class="line">                        endMergeCol = startMergeCol;</span><br><span class="line">                        perPurpose = vo.getStreet();</span><br><span class="line">                    &#125;</span><br><span class="line">                    createCell(row,cellStyle,<span class="number">2</span>,vo.getxVillage());</span><br><span class="line">                    createCell(row,cellStyle,<span class="number">3</span>,vo.getzVlillage());</span><br><span class="line">                    createCell(row,cellStyle,<span class="number">4</span>,vo.getPatrolTime());</span><br><span class="line"></span><br><span class="line">                    selectIndex = PatrolExportEnum.getWaterInCondition(vo.getWaterInCondition());</span><br><span class="line">                    <span class="keyword">if</span>(selectIndex != <span class="keyword">null</span>) &#123;</span><br><span class="line">                        <span class="keyword">if</span>(selectIndex.equals(<span class="number">3</span>))&#123;</span><br><span class="line">                            CellStyle style = colorRed(workbook,font);</span><br><span class="line">                            createCell(row,style,<span class="number">5</span> + selectIndex,no);</span><br><span class="line">                        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                            createCell(row,cellStyle,<span class="number">5</span> + selectIndex,yes);</span><br><span class="line">                        &#125;</span><br><span class="line">                        selectIndex = <span class="keyword">null</span>;</span><br><span class="line">                    &#125;</span><br><span class="line">                    selectIndex = PatrolExportEnum.getWaterOutCondition(vo.getWaterOutCondition());</span><br><span class="line">                    <span class="keyword">if</span>(selectIndex != <span class="keyword">null</span>)&#123;</span><br><span class="line">                        <span class="keyword">if</span>(selectIndex.equals(<span class="number">1</span>))&#123;</span><br><span class="line">                            CellStyle style = colorRed(workbook,font);</span><br><span class="line">                            createCell(row,style,<span class="number">9</span> + selectIndex,no);</span><br><span class="line">                        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">                            createCell(row,cellStyle,<span class="number">9</span> + selectIndex,yes);</span><br><span class="line">                        &#125;</span><br><span class="line">                        selectIndex  = <span class="keyword">null</span>;</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    selectIndex = PatrolExportEnum.getElectryCondition(vo.getElectryCondition());</span><br><span class="line">                    <span class="keyword">if</span>(selectIndex != <span class="keyword">null</span>) &#123;</span><br><span class="line">                        <span class="keyword">if</span>(selectIndex.equals(<span class="number">1</span>))&#123;</span><br><span class="line">                            CellStyle style = colorRed(workbook,font);</span><br><span class="line">                            createCell(row,style,<span class="number">11</span> + selectIndex,no);</span><br><span class="line">                        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                            createCell(row,cellStyle,<span class="number">11</span> + selectIndex,yes);</span><br><span class="line">                        &#125;</span><br><span class="line">                        selectIndex  = <span class="keyword">null</span>;</span><br><span class="line">                    &#125;</span><br><span class="line">                    List&lt;PatrolTaskExport.equCondition&gt; conditions = vo.getEquConditionList();</span><br><span class="line">                    <span class="keyword">if</span>(!CollectionUtils.isEmpty(conditions))&#123;</span><br><span class="line">                        <span class="keyword">for</span>(PatrolTaskExport.equCondition e : conditions)&#123;</span><br><span class="line">                            String value = e.getValue();</span><br><span class="line">                            String name = e.getName();</span><br><span class="line">                            <span class="keyword">if</span> (<span class="string">"格栅"</span>.equalsIgnoreCase(name)) &#123;</span><br><span class="line">                                CellStyle style = setColor(value,workbook,font);</span><br><span class="line">                                createCell(row,style,<span class="number">13</span>,value);</span><br><span class="line">                            &#125;</span><br><span class="line">                            <span class="keyword">if</span> (<span class="string">"水泵"</span>.equalsIgnoreCase(name)) &#123;</span><br><span class="line">                                CellStyle style = setColor(value,workbook,font);</span><br><span class="line">                                createCell(row,style,<span class="number">14</span> ,value);</span><br><span class="line">                            &#125;</span><br><span class="line">                            <span class="keyword">if</span> (<span class="string">"风机"</span>.equalsIgnoreCase(name)) &#123;</span><br><span class="line">                                CellStyle style = setColor(value,workbook,font);</span><br><span class="line">                                createCell(row,style,<span class="number">15</span> ,value);</span><br><span class="line">                            &#125;</span><br><span class="line">                            <span class="keyword">if</span> (<span class="string">"液位计"</span>.equalsIgnoreCase(name)) &#123;</span><br><span class="line">                                CellStyle style = setColor(value,workbook,font);</span><br><span class="line">                                createCell(row,style,<span class="number">16</span> ,value);</span><br><span class="line">                            &#125;</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line">                    selectIndex = PatrolExportEnum.getLiveCondition(vo.getIsSame());</span><br><span class="line">                    <span class="keyword">if</span>(selectIndex != <span class="keyword">null</span>) &#123;</span><br><span class="line">                        <span class="keyword">if</span> (selectIndex.equals(<span class="number">1</span>)) &#123;</span><br><span class="line">                            CellStyle style = colorRed(workbook,font);</span><br><span class="line">                            createCell(row,style,<span class="number">17</span> + selectIndex,no);</span><br><span class="line">                        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">                            createCell(row,cellStyle,<span class="number">17</span> + selectIndex,yes);</span><br><span class="line">                        &#125;</span><br><span class="line">                       selectIndex = <span class="keyword">null</span>;</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    List&lt;PatrolTaskExport.equCondition&gt; pipeCodintion = vo.getPipeCondition();</span><br><span class="line">                    <span class="keyword">if</span>(!CollectionUtils.isEmpty(pipeCodintion))&#123;</span><br><span class="line">                        <span class="keyword">for</span>(PatrolTaskExport.equCondition e : pipeCodintion)&#123;</span><br><span class="line">                            String value = e.getValue();</span><br><span class="line">                            String name = e.getName();</span><br><span class="line">                            <span class="keyword">if</span> (<span class="string">"管道"</span>.equalsIgnoreCase(name)) &#123;</span><br><span class="line">                                CellStyle style = setColor(value,workbook,font);</span><br><span class="line">                                createCell(row,style,<span class="number">19</span>,value);</span><br><span class="line">                            &#125;</span><br><span class="line">                            <span class="keyword">if</span> (<span class="string">"井盖"</span>.equalsIgnoreCase(name)) &#123;</span><br><span class="line">                                CellStyle style = setColor(value,workbook,font);</span><br><span class="line">                                createCell(row,style,<span class="number">20</span> ,value);</span><br><span class="line">                            &#125;</span><br><span class="line">                            <span class="keyword">if</span> (<span class="string">"沉沙井"</span>.equalsIgnoreCase(name)) &#123;</span><br><span class="line">                                CellStyle style = setColor(value,workbook,font);</span><br><span class="line">                                createCell(row,style,<span class="number">21</span> ,value);</span><br><span class="line">                            &#125;</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">                    selectIndex = PatrolExportEnum.getWaterCondition(vo.getWaterSupport());</span><br><span class="line">                    <span class="keyword">if</span>(selectIndex != <span class="keyword">null</span>)&#123;</span><br><span class="line">                        <span class="keyword">if</span> (selectIndex.equals(<span class="number">1</span>)) &#123;</span><br><span class="line">                            CellStyle style = colorRed(workbook,font);</span><br><span class="line">                            createCell(row,style,<span class="number">22</span> + selectIndex,no);</span><br><span class="line">                        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">                            createCell(row,cellStyle,<span class="number">22</span> + selectIndex,yes);</span><br><span class="line">                        &#125;</span><br><span class="line">                        selectIndex = <span class="keyword">null</span>;</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    createCell(row,cellStyle,<span class="number">24</span> ,vo.getAfforestCondition());</span><br><span class="line">                    createCell(row,cellStyle,<span class="number">25</span> ,vo.getPatrolPerson());</span><br><span class="line">                    createCell(row,cellStyle,<span class="number">26</span> ,vo.getContent());</span><br><span class="line">                    rowNum++;</span><br><span class="line">                    index ++;</span><br><span class="line"></span><br><span class="line">                &#125;</span><br><span class="line">                <span class="keyword">if</span>(startMergeCol &lt; endMergeCol)&#123;</span><br><span class="line">                    sheet.addMergedRegion(<span class="keyword">new</span> CellRangeAddress(startMergeCol,endMergeCol,<span class="number">1</span>,<span class="number">1</span>));</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="keyword">if</span>(xendMergeCol &gt; xStartMergeCol)&#123;</span><br><span class="line">                    sheet.addMergedRegion(<span class="keyword">new</span> CellRangeAddress(xStartMergeCol,xendMergeCol,<span class="number">2</span>,<span class="number">2</span>));</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="keyword">if</span>(zendMergeCol &gt; zStartMergeCol)&#123;</span><br><span class="line">                    sheet.addMergedRegion(<span class="keyword">new</span> CellRangeAddress(zStartMergeCol,zendMergeCol,<span class="number">3</span>,<span class="number">3</span>));</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            ByteArrayOutputStream os = <span class="keyword">new</span> ByteArrayOutputStream();</span><br><span class="line">            fileData  = <span class="keyword">new</span> FileData();</span><br><span class="line">            workbook.write(os);</span><br><span class="line">            os.flush();</span><br><span class="line">            fileData.setBytes(os.toByteArray());</span><br><span class="line">            fileData.setFileName(fileName);</span><br><span class="line"></span><br><span class="line">        &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">            log.error(<span class="string">"partrol_report_export_error"</span>);</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> fileData;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> List&lt;PatrolTaskExport&gt; <span class="title">getExportData</span><span class="params">(Map&lt;String, Object&gt; param)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">        List&lt;PatrolTaskExport&gt; list = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="number">100</span> ; i++) &#123;</span><br><span class="line">            PatrolTaskExport pa = <span class="keyword">new</span> PatrolTaskExport();</span><br><span class="line">            <span class="keyword">if</span>(i == <span class="number">6</span>) &#123;</span><br><span class="line">                pa.setStreet(<span class="string">"公孙街道"</span>);</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                pa.setStreet(<span class="string">"关山街道"</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            pa.setzVlillage(<span class="string">"黄龙山村"</span>+i);</span><br><span class="line">            pa.setPatrolTime(<span class="string">"2020-12-"</span> + i);</span><br><span class="line">            <span class="keyword">if</span>(i%<span class="number">2</span> == <span class="number">0</span>)&#123;</span><br><span class="line">                pa.setWaterInCondition(<span class="string">"正常"</span>);</span><br><span class="line">                pa.setWaterOutCondition(<span class="string">"无水"</span>);</span><br><span class="line">                pa.setIsSame(<span class="string">"一致"</span>);</span><br><span class="line">                pa.setPatrolPerson(<span class="string">"张三"</span> + i);</span><br><span class="line">                pa.setxVillage(<span class="string">"木槿村委会"</span>);</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                pa.setWaterInCondition(<span class="string">"少"</span>);</span><br><span class="line">                pa.setWaterOutCondition(<span class="string">"正常"</span>);</span><br><span class="line">                pa.setIsSame(<span class="string">"不一致"</span>);</span><br><span class="line">                pa.setPatrolPerson(<span class="string">"张三"</span> + i);</span><br><span class="line">                pa.setxVillage(<span class="string">"轰隆声村委会"</span>);</span><br><span class="line">            &#125;</span><br><span class="line">            pa.setElectryCondition(<span class="string">"故障"</span>);</span><br><span class="line">            List&lt;PatrolTaskExport.equCondition&gt; conditions = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">            conditions.add(<span class="keyword">new</span> PatrolTaskExport.equCondition(<span class="string">"格栅"</span>,<span class="string">"正常"</span>));</span><br><span class="line">            conditions.add(<span class="keyword">new</span> PatrolTaskExport.equCondition(<span class="string">"水泵"</span>,<span class="string">"异常"</span>));</span><br><span class="line">            conditions.add(<span class="keyword">new</span> PatrolTaskExport.equCondition(<span class="string">"风机"</span>,<span class="string">"正常"</span>));</span><br><span class="line">            conditions.add(<span class="keyword">new</span> PatrolTaskExport.equCondition(<span class="string">"液位计"</span>,<span class="string">"异常"</span>));</span><br><span class="line">            pa.setEquConditionList(conditions);</span><br><span class="line"></span><br><span class="line">            List&lt;PatrolTaskExport.equCondition&gt; pipeconditions = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">            pipeconditions.add(<span class="keyword">new</span> PatrolTaskExport.equCondition(<span class="string">"管道"</span>,<span class="string">"正常"</span>));</span><br><span class="line">            pipeconditions.add(<span class="keyword">new</span> PatrolTaskExport.equCondition(<span class="string">"井盖"</span>,<span class="string">"异常"</span>));</span><br><span class="line">            pipeconditions.add(<span class="keyword">new</span> PatrolTaskExport.equCondition(<span class="string">"沉沙井"</span>,<span class="string">"正常"</span>));</span><br><span class="line"></span><br><span class="line">            pa.setPipeCondition(pipeconditions);</span><br><span class="line">            pa.setWaterSupport(<span class="string">"堵塞"</span>);</span><br><span class="line">            pa.setAfforestCondition(<span class="string">"除杂草"</span>);</span><br><span class="line">            pa.setContent(<span class="string">"这是备注信息"</span>);</span><br><span class="line">            list.add(pa);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> list;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span>  String <span class="title">getMonth</span><span class="params">()</span></span>&#123;</span><br><span class="line">        Calendar date = Calendar.getInstance();</span><br><span class="line">        String year = String.valueOf(date.get(Calendar.YEAR));</span><br><span class="line">        String month = String.valueOf(date.get(Calendar.MONTH) + <span class="number">1</span>);</span><br><span class="line">        <span class="keyword">return</span> year + <span class="string">"年"</span> + month + <span class="string">"月"</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">createCell</span><span class="params">(Row row,CellStyle cellStyle ,<span class="keyword">int</span> rowNum,String value)</span></span>&#123;</span><br><span class="line">        Cell cell = row.getCell(rowNum);</span><br><span class="line">        cell.setCellStyle(cellStyle);</span><br><span class="line">        cell.setCellValue(value);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> CellStyle <span class="title">setColor</span><span class="params">(String  value ,Workbook workbook,Font font)</span></span>&#123;</span><br><span class="line">        CellStyle cellStyle = workbook.createCellStyle();</span><br><span class="line">        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);</span><br><span class="line">        cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);</span><br><span class="line">        <span class="keyword">if</span>(value.equalsIgnoreCase(<span class="string">"异常"</span>))&#123;</span><br><span class="line">            cellStyle.setFont(font);</span><br><span class="line">            <span class="keyword">return</span> cellStyle;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span>  cellStyle;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> CellStyle <span class="title">colorRed</span><span class="params">(Workbook workbook,Font font)</span></span>&#123;</span><br><span class="line">        CellStyle cellStyle = workbook.createCellStyle();</span><br><span class="line">        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);</span><br><span class="line">        cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);</span><br><span class="line">        cellStyle.setFont(font);</span><br><span class="line">        <span class="keyword">return</span> cellStyle;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>暴露接口并测试 <code>controller层</code></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Api</span>(tags = <span class="string">"巡检任务报表导出"</span>)</span><br><span class="line"><span class="meta">@RequestMapping</span>(<span class="string">"/api"</span>)</span><br><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">PatrolTaskResource</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> ExcelExportService exportService;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@ApiOperation</span>(value = <span class="string">"巡检任务报表导出"</span>)</span><br><span class="line">    <span class="meta">@GetMapping</span>(<span class="string">"/partorl-task/export"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">patrolReportExport</span><span class="params">(</span></span></span><br><span class="line"><span class="function"><span class="params">        @ApiParam(value = <span class="string">"查询条件"</span>)</span> @<span class="title">RequestParam</span><span class="params">(value = <span class="string">"param"</span>,required = <span class="keyword">false</span>)</span> String param,</span></span><br><span class="line"><span class="function">        HttpServletRequest request, HttpServletResponse response</span></span><br><span class="line"><span class="function">    )</span>&#123;</span><br><span class="line">        <span class="keyword">long</span> start =System.currentTimeMillis();</span><br><span class="line">        Map&lt;String,Object&gt; map = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">        <span class="keyword">if</span>(StringUtils.isNotEmpty(param))&#123;</span><br><span class="line">            map.put(<span class="string">"param"</span>,param);</span><br><span class="line">        &#125;</span><br><span class="line">        List&lt;PatrolTaskExport&gt; list = exportService.getExportData(map);</span><br><span class="line">        String rootPath = ImportTypeEnum.REPORT.getFilePath();</span><br><span class="line">        String fileName = ImportTypeEnum.REPORT.getFileName();</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        FileData file = exportService.exportFile(fileName,rootPath,list);</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            ExcelUtil.setResponse(request, response,file);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

</li>
</ol>
<h4 id="最终展示结果"><a href="#最终展示结果" class="headerlink" title="最终展示结果"></a>最终展示结果</h4><p><img src="https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/cbd6bed08ac84bcb8ae66f33946d0ec6~tplv-k3u1fbpfcp-watermark.image" alt></p>

      
      <!-- reward -->
      
      <div id="reward-btn">
        Donate
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>Copyright： </strong>
              Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://bodboy.gitee.io/blog/2020/11/12/java%E6%8C%89%E9%9C%80%E5%AF%BC%E5%87%BAExcel%E5%B9%B6%E8%87%AA%E5%8A%A8%E5%90%88%E5%90%8C%E5%8D%95%E5%85%83%E6%A0%BC/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/excel/" rel="tag">excel</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/java/" rel="tag">java</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/util/" rel="tag">util</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/blog/2020/11/20/iView-%E4%B8%AD-render-%E7%94%A8%E6%B3%95%E6%80%BB%E7%BB%93%E2%80%9C/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            iView 中 render 用法总结“
          
        </div>
      </a>
    
    
      <a href="/blog/2020/11/01/%E8%A7%A3%E5%86%B3%E5%A4%9A%E7%A7%8D%E7%89%88%E6%9C%ACpython%E5%86%B2%E7%AA%81%E9%97%AE%E9%A2%98/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">解决多种版本python冲突问题</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'uW8QYGvvhWmNWdiwpznJ0GVa-gzGzoHsz',
        app_key: 'LrJhMzx9qEwcMV1DJjTI6f6C',
        path: window.location.pathname,
        notify: 'false',
        verify: 'false',
        avatar: '[object Object]',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2019-2021
        <i class="ri-heart-fill heart_icon"></i> panda
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/blog/"><img src="https://portrait.gitee.com/uploads/avatars/user/1007/3023420_bodboy_1578973210.png!avatar200" alt="小熊的博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/blog/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/blog/js/jquery-2.0.3.min.js"></script>


<script src="/blog/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/blog/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/blog/dist/main.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>




<script src="/blog/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>

  
<script src="/blog/js/clickLove.js"></script>



<!-- 复制 -->



    
    <div id="music">
    
    
    
    <iframe frameborder="no" border="1" marginwidth="0" marginheight="0" width="200" height="52"
        src="//music.163.com/outchain/player?type=2&id=1297802566&auto=1&height=32"></iframe>
</div>

<style>
    #music {
        position: fixed;
        right: 15px;
        bottom: 0;
        z-index: 998;
    }
</style>
    
  </div>
</body>

</html>